package com.example.ospswagger.servlet;

import io.swagger.annotations.*;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@SwaggerDefinition(
        info = @Info(
                description = "OSP-CLOUD RESTFUL API",
                version = "1.0.0",
                title = "OSP-CLOUD RESTFUL API"
        ),
        consumes = {"application/json", "application/xml"},
        produces = {"application/json", "application/xml"},
        schemes = {SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS},
        tags = {@Tag(name = "users", description = "Operations about user")}
)
@Api(value = "/SwaggerServlet")
public class SwaggerServlet extends HttpServlet {

    @ApiOperation(httpMethod = "GET", value = "servlet获取用户信息", nickname = "/")
    @ApiResponses({@ApiResponse(code = 400, message = "非法输入")})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "integer", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "用户名", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "email", value = "EMAIL", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "age", value = "年龄", required = true, dataType = "integer", paramType = "query")})
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.getOutputStream().write("OK".getBytes());
    }
}